Skip to content

better handling of empty array from inferLanguage#1175

Merged
Janther merged 3 commits intomainfrom
remove-test
Jun 23, 2025
Merged

better handling of empty array from inferLanguage#1175
Janther merged 3 commits intomainfrom
remove-test

Conversation

@Janther
Copy link
Copy Markdown
Member

@Janther Janther commented Jun 20, 2025

There are 2 cases in which we receive an empty array from inferLanguage.

  • the range is outside of the supported versions.
  • there are ranges in the pragmas that don't intersect.

with this in mind we are defaulting to the latest supported version and return a more detailed error.

also in this PR:

I could not parse any nightly builds even when using specific versions of nightly builds of solc. Therefore I'm removing this test.

NomicFoundation/slang#1346

@Janther Janther requested a review from fvictorio June 20, 2025 21:23
@Janther Janther changed the title pragma statements don't support nightly build notation better handling of empty array from inferLanguage Jun 23, 2025
@fvictorio
Copy link
Copy Markdown
Member

I'm not sure I prefer the new behavior. I'd personally prefer to always throw an error:

  • If you are doing pragma solidity ^0.7.0; pragma solidity ^0.8.0; then this is an error. Parsing it anyway, even if it works, doesn't seem ideal to me (even if that's what the antlr-based parser did).
  • If you are doing pragma solidity 0.8.99 and that version is not supported by Slang, I think I'd also prefer to error.

The very first improvement I would do here is to try to tell apart between those two scenarios, so that users can know what's going on. I know that's not trivial though.

Then if people complain that this is too restrictive, we can consider fallback versions like you are doing here.

I don't feel super strongly about this though. If you do, and think this is the best approach, then feel free to merge.

@Janther
Copy link
Copy Markdown
Member Author

Janther commented Jun 23, 2025

the issue I'm trying to fix here is when there is a new solidity version and slang takes some time in releasing the support and then we take some time on adapting to this, and finally the user installs our latest release.
With the current solution we won't even attempt to format even if the newest solidity version has no syntax changes or the developer is not using the newest syntax.

@Janther Janther marked this pull request as draft June 23, 2025 11:46
@Janther Janther marked this pull request as ready for review June 23, 2025 11:59
@Janther Janther merged commit c900d61 into main Jun 23, 2025
7 checks passed
@Janther Janther deleted the remove-test branch June 23, 2025 12:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants